<?xml version="1.0" encoding="utf-8"?>

<layout xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:android="http://schemas.android.com/apk/res/android">

    <data>
        <variable
                name="myViewModel"
                type="com.ebookfrenzy.viewmodeldemo.ui.main.MainViewModel" />
    </data>

    <android.support.constraint.ConstraintLayout
            android:id="@+id/main"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            tools:context=".ui.main.MainFragment" tools:layout_editor_absoluteY="81dp">

        <TextView
                android:id="@+id/resultText"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text='@{safeUnbox(myViewModel.result) == 0.0 ? "Enter value" : String.valueOf(safeUnbox(myViewModel.result)) + " euros"}'
                android:layout_marginTop="104dp"
                app:layout_constraintTop_toBottomOf="@+id/dollarText" app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"/>
        <Button
                android:text="Convert"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/convertButton"
                android:onClick="@{() -> myViewModel.convertValue()}"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent" android:layout_marginTop="88dp"
                app:layout_constraintTop_toBottomOf="@+id/resultText"/>
        <EditText
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:inputType="textPersonName"
                android:ems="10"
                android:id="@+id/dollarText"
                android:text="@={myViewModel.dollarValue}"
                app:layout_constraintEnd_toEndOf="parent"
                android:layout_marginEnd="8dp" app:layout_constraintStart_toStartOf="parent"
                android:layout_marginStart="8dp" android:layout_marginTop="80dp" app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintHorizontal_bias="0.503"/>

    </android.support.constraint.ConstraintLayout>
</layout>